#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include <QMediaPlaylist>

#include "listitembox.h"
#include "musiclist.h"

enum PageType
{
    LIKE_PAGE,      // 我喜欢⻚⾯
    LOCAL_PAGE,     // 本地下载⻚⾯
    HISTORY_PAGE    // 最近播放⻚⾯
};

namespace Ui {
class CommonPage;
}

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();

    //设置不同界面ui
    void setCommonPageUi(const QString& title,const QString& image);

    void setMusicListType(PageType pageType);

    void reFresh(MusicList &musicList);     //刷新页面

    void addMusicToPlayList(MusicList &musicList,QMediaPlaylist* playerList);

    const QString& getMusicIDByIndex(int index) const;

    void setImageLable(QPixmap pixmap);

private:
    void addMusicToMusicPage(MusicList &musicList);

signals:
    void updateLikeMusic(bool isLike,QString musicId);

    void playAll(PageType pageType);    // 该信号由Music处理--在构函数中捕获

    void playMusicByIndex(CommonPage* page,int index);

private:
    // 歌单列表
    QVector<QString> _musicListOfPage;   // 具体某个⻚⾯的⾳乐，将来只需要存储⾳乐的id即可
    PageType _pageType;                  // 标记属于likePage、localPage、recentPage哪个⻚⾯
private:
    Ui::CommonPage *ui;
};

#endif // COMMONPAGE_H
